import { ViewChild,Directive, ElementRef, Input, Renderer } from '@angular/core';
import { ValidateDirective }      from './directive/validator.directive';
import {Language} from './libs/language';
import {HTTPService} from './libs/HTTPService';
import {HttpExt} from './libs/HttpExt';
import {Http, Response, Headers} from '@angular/http';
import {Global} from './libs/global';
export class BaseComponent{
    @ViewChild(ValidateDirective) private myValidate: ValidateDirective;

    public static LanguageJson : Object;
    public T : Object;

    constructor(private http:HttpExt){
        this.T = {};
        this.setLanguage();
    }
    public Validate() : boolean{
        return this.myValidate.validate();
    }
    protected setLanguage():void
    {
        if(BaseComponent.LanguageJson)
        {
            this.T = BaseComponent.LanguageJson;
            this.competedLanguage();
            return;
        }
        var that = this;
        if(this.http){
            this.http.get("/Resources/Language/Common-" + Global.getLanguage() +".json")
                    .subscribe(d=>{
                        that.T = d.json();
                        BaseComponent.LanguageJson = that.T;
                        this.competedLanguage();
                    })
        }
    }

    protected competedLanguage():void{}

}